<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content= "IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
/*    
    html {
        height: 100%;
    } */

    /* div {
        background: url("../2-15/img/4b641c180fc18ef92e290242d9919e7.png");
        display: fixed;
        margin: auto;
        height: 300px;
        width: 500px;
        line-height: 300px;
        text-align: center;
        background-color:brown;
        margin-top: 100px;
    }

    div span {
        color: #000;
    } */
</style>
</head>

<body>

<input type="text" name="" id="times">
<button id="start">开始</button>
<button id="stop">停止</button>



     
<!-- <input type="text" id="s6"><button id="s4">开始</button><button id="s5">关闭</button>

<div id="s1">
   
    <h1><span id="s2">5</span>秒后自动关闭！</h1>
</div>  -->
</body>
<script>

var setTime
window.onload=function(){
    document.getElementById('start')
    .addEventListener('click',function(){
        setTime =setInterval(function(){
            var textTime =new Date()
            var w2=textTime.getFullYear(),
w3 =textTime.getMonth() + 1,
w4=textTime.getDate(),
w6=textTime.getHours(),
w7=textTime.getMinutes(),
s=textTime.getSeconds()
document.getElementById(
    'times'
).value=`${w2}-${w3}-${w4} ${w6}:${w7}:${s}`
        },1000)
    })
    document.getElementById('stop').addEventListener('click',function(){
        clearInterval(setTime)
    })
}

// var time=null
// s4.onclick=function(){
//     time =setInterval(
//         function(){
//             var v1=new Date
//         }
//     )
// }



//     function closeAds() {
//         document.getElementById('s1').style.display = "none";
//     }
//     var d1 = document.getElementById("s2").innerText
//     var second = parseInt(d1)
//     function d3() {
//         second -= 1;
//         document.getElementById("s2").innerText = second;

//     }
//     var d2= setInterval(d3, 1000)
//     setInterval(function () {

//         if (second === 0) {
//             closeAds();
//             clearInterval(d2);
//         }
//     }, 1000)



</script>
</html>